<?php
	session_start();
    if($_SESSION['uid']==""||$_SESSION['level']!=3){
		header("Location: ./exit.php");
		exit();
	}
	include('/php/tool/submitValidate.php');
    include('/php/tool/pdo.php');
    include('/php/class/apartment.class.php');
	include('/php/bll/ApartmentBLL.php');
	
	(int)$page = isset($_GET['page']) ? $_GET['page'] : 0;
	(int)$pageSize = isset($_GET['pageSize']) ? $_GET['pageSize'] : 20;
	$property= isset($_GET['property']) ? $_GET['property'] : 0;
	$search = isset($_GET['search']) ? $_GET['search'] : '';

	$apartmentBLL=new ApartmentBLL();
	if(!$apartmentBLL->apartmentListViewValidate($page,$pageSize,$property)){
		exit();
	}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>公寓概况</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 公寓管理 <span class="c-gray en">&gt;</span> 公寓概况 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">
		<!--<button onclick="removeIframe()" class="btn btn-primary radius">关闭选项卡</button>-->
		<div class="cl pd-5 mybg-2 bk-gray">
			<span class="r">
				<button onclick="removeIframe()" class="btn btn-primary radius">关闭选项卡</button>
				 <!--<a href="javascript:;" onclick="datadel()" class="btn btn-danger radius">
				 <i class="Hui-iconfont">&#xe6e2;</i> 批量删除
				 </a>
				 <a class="btn btn-primary radius" data-title="添加公寓" data-href="apartment-add.html" onclick="Hui_admin_tab(this)" href="javascript:;">
					 <i class="Hui-iconfont">&#xe600;</i> 添加公寓
				 </a>-->
			</span>
		</div>
		<!--<select name="" class="select">
			<option value="0">全部分类</option>
			<option value="1">分类一</option>
			<option value="2">分类二</option>
		</select>-->
	</div>
	<div class="mt-10">
		<form action="apartment-list.php" method="get" class="form-horizontal mybg-2 bk-gray pt-5 pb-5">
			<div class="row cl mb-5">
				<label class="form-label col-xs-4" style="width:120px;margin:0;padding:0;line-height:31px;">公寓分类：</label>
				<div class="formControls col-xs-8 col-sm-2">
					<select id="property_select" name="property" class="select" size="1" style="height:31px">
						<option value="0" <?php echo $property==0?'selected=""':''?>>所有</option>
						<option value="1" <?php echo $property==1?'selected=""':''?>>女生公寓</option>
						<option value="2" <?php echo $property==2?'selected=""':''?>>男生公寓</option>
						<option value="3" <?php echo $property==3?'selected=""':''?>>混合公寓</option>
					</select>
				</div>
				<label class="form-label col-xs-4" style="width:120px;margin:0;padding:0;line-height:31px;">公寓名称：</label>
				<div class="formControls col-xs-8 col-sm-2">
					<input id="search" value="<?php echo $search;?>" name="search" type="text" class="input-text">
				</div>
				<button id="btn-search"  class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 查找</button>
			</div>
		</form>
	</div>
	<div class="mt-20">
			<table class="table table-border table-bordered table-bg">
					<thead>
						<tr>
							<th colspan="5" scope="col">信息统计</th>
						</tr>
						<tr class="text-c">
							<th style="display:none">公寓编号</th>
							<th>公寓名称</th>
							<th>公寓分类</th>
							<th>楼层数</th>
							<!--<th>房间总数</th>
							<th>已使用</th>-->
							<th>备注</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
					<?php
						//echo $page.'-'.$pageSize.'-'.$property.'-'.$search;
						//exit();
						$apartmentList=$apartmentBLL->getApartmentList($page,$pageSize,$property,$search);
						foreach($apartmentList as $apartment){
							$dormitorySum=$apartmentBLL->getApartmentDormitorySum($apartment['apartment_id']);
							//$dormitoryNumber=$apartmentBLL->getApartmentDormitoryNumber(2,1,$apartment['apartment_id']);
							echo '<tr class="text-c">
							<td style="display:none">'.$apartment['apartment_id'].'</td>
							<td>'.$apartment['apartment_name'].'</td>
							<td>';
							switch($apartment['property']){
								case 1:
									echo '女生宿舍楼';
									break;
								case 2:
									echo '男生宿舍楼';
									break;
								case 3:
									echo '混合宿舍楼';
									break;
								default:break;
							}
							echo '</td>
							<td>'.$apartment['floor'].'</td>';
							//<td>'.$dormitorySum.'</td>
							//<td>'.$dormitoryNumber.'</td>
							echo '<td>'.$apartment['remarks'].'</td>
							<td><a style="text-decoration:none" class="ml-5" onClick="creatIframe(\'apartment-edit.php?id='.$apartment['apartment_id'].'\',\'详细设置\');" href="javascript:;" title="编辑">
							<i class="Hui-iconfont">&#xe6df;</i></a>
							</td></tr>';
							/*<a style="text-decoration:none" class="ml-5" onClick="" href="javascript:;" title="查看">
							<i class="Hui-iconfont">&#xe725;</i></a>*/
						}
							
						?>
					</tbody>
				</table>
	</div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript">

</script> 
</body>
</html>